﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity.ModelConfiguration;

namespace Project_1.Models
{
    public class Category
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ParentId { get; set; }

        public Category(int id, string name)
        {
            this.Id = id;
            this.Name = name;
        }
        public Category()
        {

        }
    }

    public class CategoryConfiguration : EntityTypeConfiguration<Category>
    {
        public CategoryConfiguration(): base()
        {
            HasKey(p => p.Id);
            Property(p => p.Id).
                HasColumnName("Id").
                IsRequired();
            Property(p => p.Name).
                HasColumnName("Name").
                IsRequired();
            Property(p => p.ParentId).
                HasColumnName("ParentId");
            ToTable("Categories");
        }
    }

}